<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联运营商后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
 <!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">设备管理</strong> / <small>设备列表</small></div>
    </div>
    

   <div class="am-u-sm-12 am-u-md-8">
        <div class="am-btn-toolbar">
          <div class="am-btn-group am-btn-group-xs">
            <span class='typetree'>
              <select name='type'>
              <option value=99>设备类型</option>
              <foreach name="type" item="types" key="key">
                <option value={$key}>{$types}</option>
              </foreach>
              </select>
            </span>
            <span class='brandtree'>
              <select name='isfen'>
              <option value=99>分配类型</option>
              <option value=1>已经分配</option>
              <option value=2>未分配</option>
              
              </select>
            </span>

            
           

            
            <span><button type="button" class="am-btn am-btn-primary am-btn-xs" id="filter">筛选</button></span>
          </div>
        </div>
      </div>


    <div class="am-g">
      <div class="am-u-md-3 am-cf" style="float:right">
        <div class="am-fr">
          <div class="am-input-group am-input-group-sm">
            <input type="text" class="am-form-field" name="keywords" placeholder="输入公司名称 或设备号">
                <span class="am-input-group-btn">
                  <button class="am-btn am-btn-default keyseach" type="button">搜索</button>
                </span>
          </div>
        </div>
      </div>
    </div>
    <div class="am-g">
      <div class="am-u-sm-12">
        <form class="am-form">
          <table class="am-table am-table-striped am-table-hover table-main devicetable">
            <thead>
              <tr>
            <!--  <th class="table-check"><input type="checkbox" /></th> -->
                <th class="table-id">ID</th>
                <th class="table-title">设备标识号</th>
                <th class="table-title">是否分配</th>
                <th class="table-title">设备类型</th>
                <th class="table-title">公司名称</th>
                
               
              </tr>
          </thead>
          <tbody>
        <foreach name="devices" item='device'>
            <tr class="tabbox">
              <td>{$device['deviceid']}</td>
              <td>{$device['devicecode']}</td>
              <td>{$device['isfen']}</td>
              <td>{$device['devicetype']}</td>
              <td>{$device['companyname']}</td>
              
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                   <span class="am-icon-pencil-square-o">  <a href="{:U('Equipmente/edit',array('id'=>$device['deviceid']))}"> 编辑</a></span>
                 </button>

                   
      
                  
                     
                   </if>

                     </button> 
                  </div>
                </div>
              </td>
            </tr>
            </foreach>
          </tbody>
        </table>
          </tbody>
        </table>
         <!--  <div class="am-cf">
            共 {$pagearr['count']}条记录
           <div class="am-fr">
             <ul class="am-pagination">
               <li><a href="{:U('index',array('page'=>$pagearr['prevpage']))}">«</a></li>
                <?php $k=0; ?>
               <for start="$pagearr['page']" end="$pagearr['pagetotal']+1"  name='i' step="1">
                  <if condition="$k lt 6">
          <li <if condition="$i eq $pagearr['page']"> class="am-active" </if>  > <a href="{:U('Equipmente/index',array('page'=>$i))}">{$i}</a></li>
                  </if>
                <?php $k+=1;   ?>
               </for>
               
               <li><a href="{:U('Equipmente/index',array('page'=>$pagearr['nextpage']))}">»</a></li>
             </ul>
           </div>
         </div>
                 </form> -->



                   <div class="am-fr page">
      <ul class="am-pagination" >
        <li>共<label class="count"> {$pagearr['count']}</label> 条记录</li>
        <li>当前第 <label class="currentpage"> {$pagearr['page']} </label> 页</li>
       <!-- <li><label>每页&nbsp;</label><input type="text" size="2" id="pagesize" value="15" onkeypress="return listTable.changePageSize(event)"></li> -->
        <li><a href="javascript:pageajax('firpage')" class="firpage" value="1" >第一页</a></li>
        <li><a href="javascript:pageajax('prepage')" class="prepage" value="{$pagearr['page']-1}">上一页</a></li>
        <li><a href="javascript:pageajax('nexpage')" class="nexpage" value="{$pagearr['page']+1}">下一页</a></li>
        <li><a href="javascript:pageajax('laspage')" class="laspage" value="{$pagearr['totalpage']}">最末页</a></li>
       <!-- <li><input type="text" size="2" id="pageSize"class="am-input-group-sm" value="15"/ >&nbsp; <button class="am-btn-default am-btn-primary am-fr">GO</button> </li>-->
      </ul>
  </div>
</div>
        </form>

      </div>

    </div>
  </div>
  <!-- content end -->
</div>


<!-- <footer>
  <hr>
  <p class="am-padding-left">© 2014 商之联.</p>
</footer>
 -->
 <script src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}jquery.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script type="text/javascript">
</script>
<script type="text/javascript">
    var searchitem=function(page){

     //获取搜索条件
    var page = arguments[0]?arguments[0] : 1;
     var keywords=arguments[1]?arguments[1] : '';
     var $type=$("select[name='type'] option:selected").val();
     var $isfen=$("select[name='isfen'] option:selected").val();

     
     $.ajax({
        type:'POST',
        url:"{:U('Equipmente/getEquipment')}",
        data:{"type":$type,"isfen":$isfen,"keywords":keywords,"page":page},
        dataType:"json",
        success:function(result){
          // var result=jQuery.parseJSON(result);
          var $page=result.pagearr; //底部分页
          var $devices=result.devices;//设备
          
          var $tbody=$('<tbody></tbody>');
          var $string='';
        if (result.status)
        {
           
          $.each($devices,function(key,device){
            $string+="<tr>";
            $string+="<td>"+device.deviceid +"</td>";
            $string+="<td>"+device.devicecode+"</td>";
            $string+="<td>"+device.isfen +"</td>";
            $string+="<td>"+device.devicetype+"</td>";
            $string+="<td>"+device.companyname +"</td>";
            $string+="<td><span class='am-icon-pencil-square-o'></span><a href=__URL__/edit/id/"+device.deviceid+">编辑</td>";
            $string+="</tr>"; 
          });
          $tbody.append($string);
          $($tbody).replaceAll('.devicetable tbody');

          //替换分页
          $(".count").html($page.count);
          $(".currentpage").html($page.page);
          $("#pagesize").val($page.pagesize);
          $('.prepage').attr('value',$page.prevpage);
          $('.nexpage').attr('value', $page.nextpage);
          $('.laspage').attr('value',$page.pagetotal);
        }else
        {
           $tbody.append(result.message);
           $($tbody).replaceAll('.devicetable tbody');
        }
         //解析json 数据


          }
         });
    }

  
   //筛选数据
  $("#filter").click(function(){
      searchitem();
      
  })
  //翻页事件
  function pageajax(name){
     var pagevalue=$('.'+name).attr('value');

      var keywords=$("input[name='keywords']").val();
     searchitem(pagevalue,keywords);
     return false;
  }

$(function(){
  $('.keyseach').click(function(){
    var keywords=$("input[name='keywords']").val();
      searchitem(1,keywords);
     return false;
  });
})
</script>
<script type="text/javascript">
  $(function(){
       var modultname="Equipmente";

       $('.'+modultname).addClass('am-in');
});
</script>
</body>